/** 文字提示 */
class PromptWord extends eui.Component {
    private GlobleWorld: eui.Label; //文字提示
    private shadow: eui.Label;      //字体影子
    private _time: egret.Timer;   //计时器
    private static _instance: PromptWord;

    public constructor() {
        super();
        this.skinName = 'PromptWordUISkin';
        this.init();
    }
    /**初始化 */
    private init(): void {
        this.name = "PromptWord";
        this.touchEnabled = false;
        this.GlobleWorld.touchEnabled = false;
        this.alpha = 0;
        this._time = new egret.Timer(2000, 0);
        this._time.addEventListener(egret.TimerEvent.TIMER, this.removeThis, this);
    }
    /**单例 */
    public static getinstance(): PromptWord {
        if (PromptWord._instance == null)
            PromptWord._instance = new PromptWord();
        return PromptWord._instance;
    }

    /**设置警示 */
    public setSour(str: string) {
        if (this.stage == null) return;
        this.alpha = 1;
        this.GlobleWorld.text = "";
        switch (str) {
            case "word2":
                this.GlobleWorld.text = "The black ball got the foul stroke. You lose.  ";//黑球进袋犯规，你输了
                break;
            case "word1":
                this.GlobleWorld.text = "The black ball of the opposite got the foul stroke. You win.  ";//对方黑球进袋犯规，你赢了
                break;
            case "word3":
                this.GlobleWorld.text = "Kicking is overtime.   ";//击球超时 
                break;
            case "word4":
                this.GlobleWorld.text = "Foul stroke. And the opposite gets the free ball.  ";//击球犯规，对方获得自由球
                break;
            case "word5":
                this.GlobleWorld.text = "Your opposite has got the foul stroke. You get the free ball.  ";//对方击球犯规，你获得自由球
                break;
            case "word6":
                this.GlobleWorld.text = "Your round  ";//你的回合
                break;
            case "word7":
                this.GlobleWorld.text = "The opposite’s round ";//对方回合
                break;
            case "word8":
                this.GlobleWorld.text = "No.8 ball has got the pot. Break off again.  ";//8号球入袋，请重新开球
                break;
            case "word9":
                this.GlobleWorld.text = "The opposite has got the foul stroke. You’ve got the free ball behind the line.  ";//对方击球犯规，你获得线后自由球
                break;
            case "word10":
                this.GlobleWorld.text = "Foul stroke.The opposite has got the free ball behind the line.   ";//击球犯规，对方获得线后自由球
                break;
            case "word11":
                this.GlobleWorld.text = "Your colors in this round are panchromatic. ";//您本局花色为全色
                break;
            case "word12":
                this.GlobleWorld.text = "And your colors in this round is floral.  ";//您本局花色为花色
                break;
            case "word13":
                this.GlobleWorld.text = "You have achieved a goal. You  have another shot.    ";//进球成功，再来一杆
                break;
            case "word15":
                this.GlobleWorld.text = "Place the cue ball and break off.  ";//请摆放主球并开球
                break;
            default:
                this.GlobleWorld.text = str;//直接设置消息
                break;
        }

        this.shadow.text = this.GlobleWorld.text;
        this.dingshi();
    }

    /**定时清除 */
    public dingshi(): void {
        // if (this._time) {
        // egret.clearTimeout(this._time);
        // }
        // this._time = egret.setTimeout(this.removeThis, this, 2300);
        this._time.reset();
        this._time.start();

    }

    /**清除 */
    private removeThis(): void {
        this.alpha = 0;
    }
}
